home *** CD-ROM | disk | FTP | other *** search
- /****** axuucp/ax-uucico *****************************************************
- *
- * NAME
- * ax-uucico - UUCP file transfer daemon for local feeds
- *
- * SYNOPSIS
- * rx ax-uucico.rexx [feed]
- *
- * DESCRIPTION
- * ax-uucico is similar to uucico but does only perform a media-based
- * filecopy instead of a data transfer via modem.
- *
- * ax-uucico takes one single argument: the system name. ax-uucico
- * changes into the spool directory for this system and processes
- * all files matching the pattern "C.system#?" with system truncated
- * to the first 7 chars. The files are copied according to the
- * specifications in the control files; only send requests (S) are
- * processed, that means receive requests submitted with the uucp
- * command won't work, they are silently ignored and the command
- * file gets deleted without further notice.
- *
- * AUTHOR
- * Tobias Ferber <tf@ganymed.hall.sub.org>
- *
- ******************************************************************************
- *
- */
-
- feed = left(arg(1),min(length(arg(1)),7))
-
- if words(feed) < 1 then do
- say 'usage: ax-uucico [feed]'
- exit 10
- end
-
- spooldir = strfmt(axconfig("axuucp.spooldir"),"%u",feed)
-
- if ~exists(spooldir) then do
- say 'ax-uucico: No such spool directory "'spooldir'"'
- exit 10
- end
-
- tempfile = "T:ax-uucico." || pragma('Id')
- pat = "C." || feed || "?" || "????"
-
- /**/
-
- address command 'List FILES DIR "'spooldir'" PAT "'pat'" LFORMAT "%p%n" > "'tempfile'"'
- call open('fp',tempfile)
- do until eof('fp')
- fname=readln('fp')
- if words(fname) > 0 then do
- call uucico(fname)
- address command 'Delete QUIET "'fname'"'
- end
- end
-
- call close('fp')
- if exists(tempfile) then address command 'Delete QUIET "'tempfile'"'
- exit
-
- /**/
-
- uucico: procedure expose spooldir
- parse arg cfile
- if open('cf',cfile) then do
- do until eof('cf')
- str = readln('cf')
- if (words(str) > 0) & (left(str,1) ~= '#') then do
- parse var str cmd ' ' src ' ' dst ' ' .
- select
- when cmd='S' then do
- if exists(spooldir || src) then do
- address command 'Copy QUIET FROM "'spooldir || src'" TO "'spooldir || dst'"'
- address command 'Delete QUIET "'spooldir || src'"'
- end
- else say 'ax-uucico: could not send "'src'" (File not found)'
- end
- otherwise say 'ax-uucico: ignoring "'str'"'
- end
- end
- end
- call close('cf')
- end
- else say 'ax-uucico: could not read "'cfile'"'
- return
-
- /*@<axconfig><strfmt>*/
-
- /* get an AXsh configuration value */
-
- axconfig: procedure
- tempfile = "T:axconfig." || pragma('Id')
- rc_index = "AXsh:rexx/rc.index"
- var_val=""; var_file=""; var_defval="";
-
- parse upper arg var_name
- if left(var_name,1) ~= '%' then var_name = '%'var_name
- if right(var_name,1) ~= ':' then var_name = var_name':'
-
- if open('idx',rc_index,'Read') then do
- do until (eof('idx') | (var_file~=''))
- str= translate(readln('idx'),' ',d2c(9))
- if words(str) > 0 then do
- parse var str vname ' ' fname '"' defval '"'
- if upper(vname) = var_name then do
- var_file= strip(fname,'B',' 'd2c(9))
- var_defval= defval
- end
- end
- end
- call close('idx')
- end
- else say 'Could not read "'rc_index'"'
-
- if words(var_file) > 0 then do
- if open('rc',var_file,'Read') then do
- do until (eof('rc') | (var_val~=''))
- str= translate(readln('rc'),' ',d2c(9))
- if upper(word(str,1)) = var_name then var_val = strip(readln('rc'),'B',' 'd2c(9))
- end
- call close('rc')
- end
- else say 'Could not examine "'var_file'" for' var_name
- end
- else do
- if words(var_defval) > 0 then var_val= var_defval
- else say 'No such config variable:' var_name
- end
-
- return var_val
-
-
- /* substitute all occurences of 'fmt' in 'str' by 'val' */
-
- strfmt: procedure
- parse arg str,fmt,val
- p= pos(fmt,str)
- do while p>0
- str= left(str,p-1) || val || substr(str,p+length(fmt))
- p= pos(fmt,str)
- end
- return str
-
-
-